<%@ page language="java"
	import="java.util.*,com.wit.po.Company,com.wit.po.Subcompany,com.wit.po.Department,com.wit.service.impl.DLcompanyserviceImp"
	pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%
	DLcompanyserviceImp dlc = new DLcompanyserviceImp();
	List list = dlc.CompanyList();
	Company company = (Company) list.get(0);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<title>组织管理</title>
	<link href="../style/main.css" rel="stylesheet" type="text/css" />
	<style>
		body#bodyTree{margin:8px;font-size:12px;color:#000;line-height:22px;}
		body#bodyTree a{color:#000;text-decoration:none;}
		body#bodyTree a:hover{color:#3366CC;padding:2px 0px 0px 0px;}
		#bodyTree ul{margin:0;padding:0;list-style:none;background:url(<%=basePath%>/images/tree/ullist.gif) repeat-y;}
		#bodyTree ul li{list-style:none;}
		#bodyTree .treeview li{background:transparent url(<%=basePath%>/images/tree/list.gif) no-repeat left center;padding-left:15px;/*tree list*/}
		#bodyTree .treeview li.submenu{background:transparent url(<%=basePath%>/images/tree/closed.gif) no-repeat left 0px;/*4 sub menu*/}
		#bodyTree .treeview li.closefolder{background:transparent url(<%=basePath%>/images/tree/closed.gif) no-repeat left 0px;/*closefolder style*/}
		#bodyTree .treeview li.openfolder{background:transparent url(<%=basePath%>/images/tree/open.gif) no-repeat left 0px;/*openfolder style*/}
		#bodyTree .treeview li.submenu ul{display:none;}
		#bodyTree ul li a.cur{font-weight:bold;color:#3366CC;padding:2px 2px 0px 2px;/*the current style*/}
		#bodyTree .treeview .submenu i{width:12px;height:12px;font-style:normal;font-size:10px;margin-left:-15px;margin-top:5px;float:left;display:inline;background:url(<%=basePath%>/images/tree/transparent.gif) no-repeat center; cursor:pointer;}
	</style>
	<script type="text/javascript" src="<%=basePath%>/images/tree/simpletreemenu.js">
	  </script>
  
  </head> 
  <body id="bodyTree">
  <script type="text/javascript">
  function test(a)
  {
  alert(a);
  window.open("GetshowDepartment?departmentId="+a+"","_self");
  }
  </script>
      <!-- 实际菜单数据开始 -->
	<div id="cmsTree">
				
					<ul id="treemenu3" class="treeview">
						<li>
							<strong>组织架构</strong>
							<a href="javascript:ddtreemenu.flatten('treemenu3', 'expand')"><strong>展开</strong>
							</a>
							<a href="javascript:ddtreemenu.flatten('treemenu3', 'contact')"><strong>收缩</strong>
							</a>
						</li>
						<li>
							<i></i><span onclick="GetTree('<%=company.getCompanyNum()%>')"><%=company.getCompanynameC()%></span>
							<%
							    List<Department> dlist=dlc.ReturncompanyD(company.getCompanyNum()); 
							    if(dlist.size()>0)
							    {
							%>
							<ul>
							        <%
							        for(int i=0;i<dlist.size();i++)
							        { 
							        %>
							        <li><span onclick="dep2('<%=dlist.get(i).getDepartmentId()%>')"><%=dlist.get(i).getDepartNameC() %></span></li>
							        <%
							        }
							        %>
							
							<%
							   }
							 %>
							<%
								List<Subcompany> flist = dlc.FirstLevel();
								if (flist.size() > 0) {
							%>
							<ul>
								<%
									for (int i = 0; i < flist.size(); i++) {
											//第一层代理
											Subcompany sub = flist.get(i);
								%>

								<li>
									<i></i><span onclick="GetMessage('<%=sub.getSubcommpanyId()%>')"><%=sub.getSshortName()%></span>
									<%
									   List<Department> alist=dlc.ReturnSubcompanyD(sub.getSubcommpanyId()); 
							           if(alist.size()>0)
							          {
									%>
									   <ul>
									    <%
									    for(int j=0;j<alist.size();j++)
									    {
									    %>
									    <li><span onclick="dep2('<%=alist.get(j).getDepartmentId() %>')"><%=alist.get(j).getDepartNameC() %></span></li>
									    <%
									    } 
									    %>
									   </ul>
									<% 
									   }
									%>
									<%
										int size = sub.getSubcompanies().size();
												if (size > 0) {
													//第二层
									%>
									<ul>
										<%
											Iterator it = sub.getSubcompanies().iterator();
														while (it.hasNext()) {
															Subcompany selevel = (Subcompany) it.next();
										%>

										<li>
											<i></i><span onclick="GetMessage('<%=selevel.getSubcommpanyId()%>')"><%=selevel.getSshortName()%></span>
											<%
										  	 List<Department> blist=dlc.ReturnSubcompanyD(selevel.getSubcommpanyId()); 
								          	 if(blist.size()>0)
								          	{
										   %>
										   <ul>
										    <%
										    for(int k=0;k<blist.size();k++)
										    {
										    %>
										    <li><span onclick="dep2('<%=blist.get(k).getDepartmentId() %>')"><%=blist.get(k).getDepartNameC() %></span></li>
										    <%
										    } 
										    %>
										   </ul>
											<% 
										  	 }
											%>
											<%
												int three = selevel.getSubcompanies().size();
																if (three > 0) {
																	//第三层
											%>
											<ul>
												<%
													Iterator threeit = selevel.getSubcompanies()
																				.iterator();
																		while (threeit.hasNext()) {
																			Subcompany threelevelc = (Subcompany) threeit
																					.next();
												%>

												<li>
													<i></i><span onclick="GetMessage('<%=threelevelc.getSubcommpanyId()%>')"><%=threelevelc.getSshortName()%></span>
													<%
												  	 List<Department> clist=dlc.ReturnSubcompanyD(threelevelc.getSubcommpanyId()); 
										          	 if(clist.size()>0)
										          	{
												   %>
												   <ul>
												    <%
												    for(int k=0;k<clist.size();k++)
												    {
												    %>
												    <li><span onclick="dep2('<%=clist.get(k).getDepartmentId() %>')"><%=clist.get(k).getDepartNameC() %></span></li>
												    <%
												    } 
												    %>
												   </ul>
													<% 
												  	 }
													%>
													<%
														int four = threelevelc.getSubcompanies()
																						.size();
																				if (four > 0) {
																					//第四层
													%>
													<ul>
														<%
															Iterator fourlevel = threelevelc
																								.getSubcompanies().iterator();
																						while (fourlevel.hasNext()) {
																							Subcompany fourlevelc = (Subcompany) fourlevel
																									.next();
														%>

														<li>
															<i></i><span onclick="GetMessage('<%=fourlevelc.getSubcommpanyId()%>')"><%=fourlevelc
													.getSshortName()%></span>
													<%
												  	 List<Department> elist=dlc.ReturnSubcompanyD(fourlevelc.getSubcommpanyId()); 
										          	 if(elist.size()>0)
										          	{
												   %>
												   <ul>
												    <%
												    for(int k=0;k<elist.size();k++)
												    {
												    %>
												    <li><span onclick="dep2('<%=elist.get(k).getDepartmentId() %>')"><%=elist.get(k).getDepartNameC() %></span></li>
												    <%
												    } 
												    %>
												   </ul>
													<% 
												  	 }
													%>
															<%
																int five = fourlevelc
																										.getSubcompanies().size();
																								if (five > 0) {
															%>
															<ul>
																<%
																	Iterator fivelevel = fourlevelc
																												.getSubcompanies()
																												.iterator();

																										while (fivelevel.hasNext()) {
																											Subcompany fivelevelc = (Subcompany) fivelevel
																													.next();
																%>
																<li><span onclick="GetMessage('<%=fivelevelc.getSubcommpanyId()%>')"><%=fivelevelc
															.getSshortName()%></span>
															<%
												  	 List<Department> klist=dlc.ReturnSubcompanyD(fivelevelc.getSubcommpanyId()); 
										          	 if(klist.size()>0)
										          	{
												   %>
												   <ul>
												    <%
												    for(int k=0;k<klist.size();k++)
												    {
												    %>
												    <li><span onclick="dep2('<%=klist.get(k).getDepartmentId() %>')"><%=klist.get(k).getDepartNameC() %></span></li>
												    <%
												    } 
												    %>
												   </ul>
													<% 
												  	 }
													%>
															</li>
																<%
																	}
																%>
															</ul>
															<%
																}
															%>
														</li>
												</li>
												<%
													}
												%>
											</ul>
											<%
												}
											%>
										</li>
										<%
											}
										%>
									</ul>
									<%
										}
									%>
								</li>
								<%
									}
								%>
							</ul>
							<%
								}
							%>
						</li>
						<%
							//到这里第一层结束
								}
						%>
					</ul>
					</ul>
					<%
						}
					%>
					
					
				</div>
	<!-- 实际菜单数据结束 -->
	
	
	<script type="text/javascript">
	ddtreemenu.createTree("treemenu3", true)
	</script>
</body>
</html>
